package com.myc.train.business.controller.admin;

import com.myc.train.common.resp.CommonResp;
import com.myc.train.common.resp.PageResp;
import com.myc.train.business.req.TrainSeatQueryReq;
import com.myc.train.business.req.TrainSeatSaveReq;
import com.myc.train.business.resp.TrainSeatQueryResp;
import com.myc.train.business.service.TrainSeatService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * 车座管理
 * */
@RestController
@RequestMapping("/admin/train-seat")
public class TrainSeatAdminController {


    @Autowired
    private TrainSeatService service;

    @RequestMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody TrainSeatSaveReq req){
        service.save(req);
        return new CommonResp<>();
    }

    @RequestMapping("/query-list")
    public CommonResp<PageResp<TrainSeatQueryResp>> queryList(@Valid TrainSeatQueryReq req){
               PageResp<TrainSeatQueryResp> list = service.queryList(req);
        return new CommonResp<>(list);
    }


    /**
     *
     * 删除接口，若是根据多个条件删除用下面的-------@PathVariable的含义是路径对应，要把{}中的名字和传参的名字对应
     *     @DeleteMapping("/delete/{id}/{memberID}")
     *     public CommonResp<Object> delete1(@PathVariable Long id,@PathVariable Long memberID)
     * */
    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id){
        service.delete(id);
        return new CommonResp<>();
    }
}
